define(['egis'], function (egis) {
    Window.deserializer = Window.deserializer || new egis.core.Deserializer();
    Window.container = Window.container || {};
    dsBridge.register('create_RestWRPSService', function (sourceId, url, http, authType, clientId, clientSecret,tokenUrl) {
        var restHttp = Window.container[http];
        var restGeoService = new egis.ews.RestWRPSService({
            url: url,
            http: restHttp,
            deserializer: Window.deserializer,
            authType: authType,
            clientId: clientId,
            clientSecret: clientSecret,
            tokenUrl:tokenUrl
        });
        Window.container[sourceId] = restGeoService;
    })

    dsBridge.registerAsyn('RestWRPSService_driving', function (sourceId, drivingInput, responseCallback) {
        var restWRPSService = Window.container[sourceId];
        drivingInput = Window.deserializer.createJsInstance(JSON.parse(drivingInput));
        restWRPSService.driving(drivingInput).then(function (value) {
            responseCallback(JSON.stringify(value));
        })
    })

    dsBridge.registerAsyn('RestWRPSService_transit', function (sourceId, transitInput, responseCallback) {
        var restWRPSService = Window.container[sourceId];
        transitInput = Window.deserializer.createJsInstance(JSON.parse(transitInput));
        restWRPSService.transit(transitInput).then(function (value) {
            responseCallback(JSON.stringify(value));
        })
    })


    dsBridge.registerAsyn('RestWRPSService_riding', function (sourceId, ridingInput, responseCallback) {
        var restWRPSService = Window.container[sourceId];
        ridingInput = Window.deserializer.createJsInstance(JSON.parse(ridingInput));
        restWRPSService.riding(ridingInput).then(function (value) {
            responseCallback(JSON.stringify(value));
        })
    })

    dsBridge.registerAsyn('RestWRPSService_walking', function (sourceId, walkingInput, responseCallback) {
        var restWRPSService = Window.container[sourceId];
        walkingInput = Window.deserializer.createJsInstance(JSON.parse(walkingInput));
        restWRPSService.walking(walkingInput).then(function (value) {
            responseCallback(JSON.stringify(value));
        })
    })

})